package org.wkg.lesson09;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class Demo_906 {

    public static void main(String[] args) {
        ThreadPoolExecutor threadpool = new ThreadPoolExecutor(
                5, 10, 1, TimeUnit.SECONDS,
                new LinkedBlockingQueue<>(5),
                new ThreadPoolExecutor.CallerRunsPolicy()
        );

        for (int i = 0; i < 50; i++) {
            int task = i + 1;
            threadpool.submit(() -> {
                System.out.println("执行任务：" + task + " " + Thread.currentThread().getName());

            });
        }

    }
}
